package com.motorhome.manage.dao.impl;

import com.motorhome.base.dao.impl.BaseDaoImpl;
import com.motorhome.manage.dao.UserDao;
import com.motorhome.manage.domain.ManageUser;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

/**
 * @author: John
 */
@Repository
public class UserDaoImpl extends BaseDaoImpl implements UserDao {

    @Override
    public ManageUser queryUserById(Long userId) {
        return this.queryForObject("select id, user_name, login_name, login_pass, phone from m_user where id = ?",
                new BeanPropertyRowMapper<ManageUser>(ManageUser.class),
                userId);
    }

    @Override
    public ManageUser queryUserByLoginName(String loginName) {
        return this.queryForObject("select id, user_name, login_name, login_pass, phone from m_user where login_name = ?",
                new BeanPropertyRowMapper<ManageUser>(ManageUser.class),
                loginName);
    }

    @Override
    public int updatePass(Long userId, String password) {
        return this.update("update m_user set login_pass = ? where id = ?", password, userId);
    }

}
